<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../../../assets/docs.css" rel="stylesheet" type="text/css" media="screen" />
<title>MooTools 1.3 Documentation - Types/Date</title>
</head>

<body>
  <div class="doc">
    <div class="methods">
      <h4 class="menu-item"><a href="#Date">Date</a></h4>
      <div class="menu-item"><a href="#Date:get">get</a></div>
      <div class="menu-item"><a href="#Date:set">set</a></div>
      <div class="menu-item"><a href="#Date:clone">clone</a></div>
      <div class="menu-item"><a href="#Date:increment">increment</a></div>
      <div class="menu-item"><a href="#Date:decrement">decrement</a></div>
      <div class="menu-item"><a href="#Date:isLeapYear">isLeapYear</a></div>
      <div class="menu-item"><a href="#Date:clearTime">clearTime</a></div>
      <div class="menu-item"><a href="#Date:diff">diff</a></div>
      <div class="menu-item"><a href="#Date:getTimezone">getTimezone</a></div>
      <div class="menu-item"><a href="#Date:getGMTOffset">getGMTOffset</a></div>
      <div class="menu-item"><a href="#Date:getWeek">getWeek</a></div>
      <div class="menu-item"><a href="#Date:getOrdinal">getOrdinal</a></div>
      <div class="menu-item"><a href="#Date:getDayOfYear">getDayOfYear</a></div>
      <div class="menu-item"><a href="#Date:getLastDayOfMonth">getLastDayOfMonth</a></div>
      <div class="menu-item"><a href="#Date:format">format</a></div>
      <div class="menu-item"><a href="#Date:toISOString">toISOString</a></div>
      <div class="menu-item"><a href="#Date:parse">parse</a></div>
      <h4 class="menu-item"><a href="#Static">Static</a></h4>
      <div class="menu-item"><a href="#Date:defineFormat">defineFormat</a></div>
      <div class="menu-item"><a href="#Date:defineFormats">defineFormats</a></div>
      <div class="menu-item"><a href="#Date:staticParse">staticParse</a></div>
      <div class="menu-item"><a href="#Date:defineParser">defineParser</a></div>
      <div class="menu-item"><a href="#Date:defineParsers">defineParsers</a></div>
      <div class="menu-item"><a href="#Date:define2DigitYearStart">define2DigitYearStart</a></div>
    </div>
    <div class="l-border r-border span-15 content">
      <h1 id="Date"><a href="#Date">Type: Date</a></h1>
      <p class="description">Extends the Date Type to include more powerful parsing and formatting functions.</p>
      <h3>Tutorial/Demo</h3>
      <ul>
        <li><a href="http://www.clientcide.com/wiki/cnet-libraries/03-native/00-date">Online Tutorial/Demo</a></li>
      </ul>
      <h3>Authors</h3>
      <ul>
        <li>Nicholas Barthelemy - https://svn.nbarthelemy.com/date-js/</li>
        <li>Harald Kirshner - mail [at] digitarald.de; http://digitarald.de</li>
        <li>Aaron Newton - aaron [dot] newton [at] cnet [dot] com</li>
        <li>Scott Kyle - scott [at] appden.com; http://appden.com</li>
      </ul>
      <h3>License</h3>
      <p>MIT-style license</p>
      <h2 id="Date:get"><a href="#Date:get">Date Method: get</a></h2>
      <p class="description">Retrieves a property of a date.</p>
      <h3>Syntax</h3>
      <pre class="javascript">date.<span class="me1">get</span><span class="br0">(</span>key<span class="br0">)</span>;

</pre>
      <h3>Arguments</h3>
      <ol>
        <li>key - (<em>string</em>) the key of the value you wish to get</li>
      </ol>
      <h3>Returns</h3>
      <ul>
        <li>(<em>mixed</em>) the corresponding value for the key supplied</li>
      </ul>
      <h3>Notes</h3>
      <ul>
        <li>All of the native date methods work with <em>get</em> in addition to most of the <em>get...</em> methods added in Date.js. These are: "Date", "Day", "FullYear", "Hours", "Milliseconds", "Minutes", "Month", "Seconds", "Time", "TimezoneOffset", "Week", "Timezone", "GMTOffset", "Ordinal", "DayOfYear", "LastMonth", "UTCDate", "UTCDay", "UTCFullYear", "AMPM", "UTCHours", "UTCMilliseconds", "UTCMinutes", "UTCMonth", "UTCSeconds"</li>
        <li> <em>get</em> is <strong>not</strong> case sensitive; so you can do <em>get('date')</em> </li>
      </ul>
      <h3>Aliases</h3>
      <p>The following aliases/shortcuts are available:</p>
      <ul>
        <li>ms: "Milliseconds"</li>
        <li>year: "FullYear"</li>
        <li>min: "Minutes"</li>
        <li>mo: "Month"</li>
        <li>sec: "Seconds"</li>
        <li>hr: "Hours"</li>
      </ul>
      <h3>Examples</h3>
      <pre class="javascript">date.<span class="me1">get</span><span class="br0">(</span><span class="st0">'date'</span><span class="br0">)</span>;
date.<span class="me1">get</span><span class="br0">(</span><span class="st0">'year'</span><span class="br0">)</span>;
date.<span class="me1">get</span><span class="br0">(</span><span class="st0">'ms'</span><span class="br0">)</span>;

<span class="co1">//etc.</span>
</pre>
      <h2 id="Date:set"><a href="#Date:set">Date Method: set</a></h2>
      <p class="description">Sets a property of a date.</p>
      <h3>Syntax</h3>
      <pre class="javascript">date.<span class="me1">set</span><span class="br0">(</span>arguments<span class="br0">)</span>;

</pre>
      <h3>Arguments</h3>
      <ul>
        <li>Two Arguments (property, value)
          <ol>
            <li>property - (<em>string</em>) the property that you want to set</li>
            <li>value - (<em>mixed</em>) the value for the key</li>
          </ol>
        </li>
        <li>One Argument (properties)
          <ol>
            <li>properties - (<em>object</em>) Object with its keys/value pairs representing the properties and values to set for the Date (as described below).</li>
          </ol>
        </li>
      </ul>
      <h3>Notes</h3>
      <ul>
        <li>All of the native date methods work with <em>set</em>. These are: "Date", "FullYear", "Hours", "Milliseconds", "Minutes", "Month", "Seconds", "Time", "UTCDate", "UTCFullYear", "UTCHours", "UTCMilliseconds", "UTCMinutes", "UTCMonth", "UTCSeconds"</li>
        <li> <em>set</em> is <strong>not</strong> case sensitive; so you can do <em>set('date')</em> </li>
      </ul>
      <h3>Aliases</h3>
      <p>The following aliases/shortcuts are available:</p>
      <ul>
        <li>ms: "Milliseconds"</li>
        <li>year: "FullYear"</li>
        <li>min: "Minutes"</li>
        <li>mo: "Month"</li>
        <li>sec: "Seconds"</li>
        <li>hr: "Hours"</li>
      </ul>
      <h3>Examples</h3>
      <pre class="javascript">date.<span class="me1">set</span><span class="br0">(</span><span class="st0">'date'</span>, <span class="nu0">12</span><span class="br0">)</span>;
date.<span class="me1">set</span><span class="br0">(</span><span class="st0">'year'</span>, <span class="nu0">2001</span><span class="br0">)</span>;
date.<span class="me1">set</span><span class="br0">(</span><span class="st0">'ms'</span>, <span class="nu0">100</span><span class="br0">)</span>;

<span class="co1">//etc.</span>
</pre>
      <h2 id="Date:clone"><a href="#Date:clone">Date Method: clone</a></h2>
      <p class="description">Returns a copy of the date.</p>
      <h3>Syntax</h3>
      <pre class="javascript">date.<span class="me1">clone</span><span class="br0">(</span><span class="br0">)</span>;

</pre>
      <h3>Example</h3>
      <pre class="javascript"><span class="kw2">var</span> today = <span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>;
<span class="kw2">var</span> todayCopy = today.<span class="me1">clone</span><span class="br0">(</span><span class="br0">)</span>;

</pre>
      <h3>Returns</h3>
      <ul>
        <li>(<em>date</em>) A new Date object with the same date/time set as the cloned one.</li>
      </ul>
      <h2 id="Date:increment"><a href="#Date:increment">Date Method: increment</a></h2>
      <p class="description">Increments a value in the date.</p>
      <h3>Syntax</h3>
      <pre class="javascript">date.<span class="me1">increment</span><span class="br0">(</span>interval, times<span class="br0">)</span>;
</pre>
      <h3>Arguments</h3>
      <ol>
        <li>interval - (<em>string</em>, optional) "day", "month", etc. (defaults to 'day')</li>
        <li>times - (<em>integer</em>, optional) the number of times to increment (defaults to 1)</li>
      </ol>
      <h3>Examples</h3>
      <pre class="javascript"><span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>.<span class="me1">increment</span><span class="br0">(</span><span class="st0">'day'</span>, <span class="nu0">4</span><span class="br0">)</span>; <span class="co1">//four days from now</span>

<span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>.<span class="me1">increment</span><span class="br0">(</span><span class="br0">)</span>; <span class="co1">//tomorrow</span>
<span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>.<span class="me1">increment</span><span class="br0">(</span><span class="st0">'year'</span><span class="br0">)</span>; <span class="co1">//one year from now</span>

</pre>
      <h3>Returns</h3>
      <ul>
        <li>(<em>Date</em>) This Date.</li>
      </ul>
      <h3>Note</h3>
      <ul>
        <li>the only acceptable values for interval are <strong>year</strong>, <strong>month</strong>, <strong>week</strong>, <strong>day</strong>, <strong>hour</strong>, <strong>minute</strong>, <strong>second</strong>, and <strong>ms</strong> </li>
      </ul>
      <h2 id="Date:decrement"><a href="#Date:decrement">Date Method: decrement</a></h2>
      <p class="description">Decrements a value in the date. See <a href="#Date:increment">Date:increment</a>.</p>
      <h3>Returns</h3>
      <ul>
        <li>(<em>Date</em>) This Date.</li>
      </ul>
      <h3>Note</h3>
      <ul>
        <li>the only acceptable values for interval are <strong>year</strong>, <strong>month</strong>, <strong>week</strong>, <strong>day</strong>, <strong>hour</strong>, <strong>minute</strong>, <strong>second</strong>, and <strong>ms</strong> </li>
      </ul>
      <h2 id="Date:isLeapYear"><a href="#Date:isLeapYear">Date Method: isLeapYear</a></h2>
      <p class="description">Returns true if the date is in a leap year.</p>
      <h3>Syntax</h3>
      <pre class="javascript"><span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>.<span class="me1">isLeapYear</span><span class="br0">(</span><span class="br0">)</span>;

</pre>
      <h3>Returns</h3>
      <ul>
        <li>(<em>boolean</em>) true if date is in a leap year</li>
      </ul>
      <h2 id="Date:clearTime"><a href="#Date:clearTime">Date Method: clearTime</a></h2>
      <p class="description">Sets the hours, minutes, seconds, and milliseconds to zero.</p>
      <h3>Syntax</h3>
      <pre class="javascript"><span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>.<span class="me1">clearTime</span><span class="br0">(</span><span class="br0">)</span>; <span class="co1">//midnight on the dot</span>
</pre>
      <h3>Returns</h3>
      <ul>
        <li>(<em>Date</em>) This Date.</li>
      </ul>
      <h2 id="Date:diff"><a href="#Date:diff">Date Method: diff</a></h2>
      <p class="description">Compares two dates.</p>
      <h3>Syntax</h3>
      <pre class="javascript">date.<span class="me1">diff</span><span class="br0">(</span>otherDate<span class="br0">[</span>, resolution<span class="br0">]</span><span class="br0">)</span>;
</pre>
      <h3>Arguments</h3>
      <ol>
        <li>otherDate - (<em>date</em>) the other date to compare this one to.</li>
        <li>resolution - (<em>string</em>, optional) how fine a comparision to make; 'day', 'month', etc. defaults to 'day'</li>
      </ol>
      <h3>Examples</h3>
      <pre class="javascript"><span class="kw2">var</span> today = <span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>;

<span class="kw2">var</span> tomorrow = today.<span class="me1">clone</span><span class="br0">(</span><span class="br0">)</span>.<span class="me1">increment</span><span class="br0">(</span><span class="br0">)</span>;
today.<span class="me1">diff</span><span class="br0">(</span>tomorrow<span class="br0">)</span>; <span class="co1">//returns 1</span>

today.<span class="me1">diff</span><span class="br0">(</span>tomorrow, <span class="st0">'minute'</span><span class="br0">)</span>; <span class="co1">//returns 1440</span>
</pre>
      <h3>Returns</h3>
      <ul>
        <li>(<em>integer</em>) the difference in time at the specified resolution</li>
      </ul>
      <h2 id="Date:getTimezone"><a href="#Date:getTimezone">Date Method: get('timezone')</a></h2>
      <p class="description">Returns the time zone for the date. Example: "GMT".</p>
      <h3>Syntax</h3>
      <pre class="javascript"><span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>.<span class="me1">get</span><span class="br0">(</span><span class="st0">'timezone'</span><span class="br0">)</span>; <span class="co1">//"GMT" or whatever</span>

</pre>
      <h3>Returns</h3>
      <ul>
        <li>(<em>string</em>) the time zone stamp ("GMT" for example);</li>
      </ul>
      <h2 id="Date:getGMTOffset"><a href="#Date:getGMTOffset">Date Method: get('gmtoffset')</a></h2>
      <p class="description">Returns the offset to GMT <em>as a string</em>. Example: "-0800".</p>
      <h3>Syntax</h3>
      <pre class="javascript"><span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>.<span class="me1">get</span><span class="br0">(</span><span class="st0">'gmtoffset'</span><span class="br0">)</span>; <span class="co1">//"-0800" or whatever</span>

</pre>
      <h3>Returns</h3>
      <ul>
        <li>(<em>string</em>) the GMT offset</li>
      </ul>
      <h2 id="Date:getWeek"><a href="#Date:getWeek">Date Method: get('week')</a></h2>
      <h3 class="description">Syntax</h3>
      <pre class="javascript"><span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>.<span class="me1">get</span><span class="br0">(</span><span class="st0">'week'</span><span class="br0">)</span>;
</pre>
      <h3>Returns</h3>
      <ul>
        <li>(<em>integer</em>) the week of the year for the date (i.e. 1 - 52).</li>
      </ul>
      <h2 id="Date:getOrdinal"><a href="#Date:getOrdinal">Date Method: get('ordinal')</a></h2>
      <h3 class="description">Syntax</h3>
      <pre class="javascript"><span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>.<span class="me1">get</span><span class="br0">(</span><span class="st0">'ordinal'</span><span class="br0">)</span>;

</pre>
      <h3>Returns</h3>
      <ul>
        <li>(<em>string</em>) the ordinal for the day ('th', 'st', 'nd', etc).</li>
      </ul>
      <h2 id="Date:getDayOfYear"><a href="#Date:getDayOfYear">Date Method: get('dayofyear')</a></h2>
      <h3 class="description">Syntax</h3>
      <pre class="javascript"><span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>.<span class="me1">get</span><span class="br0">(</span><span class="st0">'dayofyear'</span><span class="br0">)</span>;
</pre>
      <ul>
        <li>(<em>integer</em>) the day of the year (i.e. for Dec. 10, you'll get 344 in a non-leap year).</li>
      </ul>
      <h2 id="Date:getLastDayOfMonth"><a href="#Date:getLastDayOfMonth">Date Method: get('lastdayofmonth')</a></h2>
      <h3 class="description">Syntax</h3>
      <pre class="javascript"><span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>.<span class="me1">get</span><span class="br0">(</span><span class="st0">'lastdayofmonth'</span><span class="br0">)</span>;

</pre>
      <h3>Returns</h3>
      <ul>
        <li>(<em>integer</em>) the last day of the month (i.e. for December, you'll get 31).</li>
      </ul>
      <h2 id="Date:format"><a href="#Date:format">Date Method: format</a></h2>
      <p class="description">Outputs the date into a specific format.</p>
      <h3>Syntax</h3>
      <pre class="javascript"><span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>.<span class="me1">format</span><span class="br0">(</span>format<span class="br0">)</span>;
</pre>
      <h3>Arguments</h3>
      <ol>
        <li>format - (<em>string</em>) a string format for the output. Use the keys below with percent signs to get a desired output. Defaults to "%x %X", which renders "12/31/2007 03:45PM"</li>
      </ol>
      <h3>Keys</h3>
      <ul>
        <li>a - short day ("Mon", "Tue")</li>
        <li>A - full day ("Monday")</li>
        <li>b - short month ("Jan", "Feb")</li>
        <li>B - full month ("January")</li>
        <li>c - the full date to string ("Mon Dec 10 14:35:42 2007"; %a %b %d %H:%m:%S %Y)</li>
        <li>d - the date to two digits (01, 05, etc)</li>
        <li>e - the date as one digit (1, 5, 12, etc)</li>
        <li>H - the hour to two digits in military time (24 hr mode) (00, 11, 14, etc)</li>
        <li>I - the hour as a decimal number using a 12-hour clock (range 01 to 12).</li>
        <li>j - the day of the year to three digits (001 to 366, is Jan 1st)</li>
        <li>k - the hour (24-hour clock) as a digit (range 0 to 23). Single digits are preceded by a blank space.</li>
        <li>k - the hour (12-hour clock) as a digit (range 1 to 12). Single digits are preceded by a blank space.</li>
        <li>L - the time in milliseconds (three digits; "081")</li>
        <li>m - the numerical month to two digits (01 is Jan, 12 is Dec)</li>
        <li>M - the minutes to two digits (01, 40, 59)</li>
        <li>o - the ordinal of the day of the month in the current language ("st" for the 1st, "nd" for the 2nd, etc.)</li>
        <li>p - the current language equivalent of either AM or PM</li>
        <li>s - the Unix Epoch Time timestamp</li>
        <li>S - the seconds to two digits (01, 40, 59)</li>
        <li>U - the week to two digits (01 is the week of Jan 1, 52 is the week of Dec 31)</li>
        <li>w - the numerical day of the week, one digit (0 is Sunday, 1 is Monday)</li>
        <li>x - the date in the current language preferred format. en-US: %m/%d/%Y (12/10/2007)</li>
        <li>X - the time in the current language preferred format. en-US: %I:%M%p (02:45PM)</li>
        <li>y - the short year (two digits; "07")</li>
        <li>Y - the full year (four digits; "2007")</li>
        <li>z - the GMT offset ("-0800")</li>
        <li>Z - the time zone ("GMT")</li>
        <li>% - returns % (example: %y%% = 07%)</li>
      </ul>
      <h3>Shortcuts</h3>
      <p>These shortcuts are NOT preceded by the percent sign.</p>
      <ul>
        <li>db - "%Y-%m-%d %H:%M:%S",</li>
        <li>compact - "%Y%m%dT%H%M%S",</li>
        <li>iso8601 - "%Y-%m-%dT%H:%M:%S%T",</li>
        <li>rfc822 - "%a, %d %b %Y %H:%M:%S %Z",</li>
        <li>short - "%d %b %H:%M",</li>
        <li>long - "%B %d, %Y %H:%M"</li>
      </ul>
      <p>See <a href="#Date:defineFormat">Date:defineFormat</a> to define new shortcuts.</p>
      <h3>Examples</h3>
      <pre class="javascript"><span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>.<span class="me1">format</span><span class="br0">(</span><span class="st0">'db'</span><span class="br0">)</span>; <span class="co1">//1999-12-31 23:59:59</span>

<span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>.<span class="me1">format</span><span class="br0">(</span><span class="st0">'%x'</span><span class="br0">)</span>; <span class="co1">//12/31/1999</span>
<span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>.<span class="me1">format</span><span class="br0">(</span><span class="st0">'%y'</span><span class="br0">)</span>; <span class="co1">//99</span>

</pre>
      <h3>Returns</h3>
      <ul>
        <li>(<em>string</em>) the corresponding format for the Date.</li>
      </ul>
      <h2 id="Date:toISOString"><a href="#Date:toISOString">Date Method: toISOString</a></h2>
      <p class="description">Outputs the date in the ISO-8601 standard format (i.e. 1999-12-31T11:59:59-0800).</p>
      <h3>Syntax</h3>
      <pre class="javascript"><span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>.<span class="me1">toISOString</span><span class="br0">(</span><span class="br0">)</span>;  <span class="co1">//equivalent to format('iso8601')</span>
</pre>
      <h3>Returns</h3>
      <ul>
        <li>(<em>string</em>) the date in ISO-8601 format.</li>
      </ul>
      <h2 id="Date:parse"><a href="#Date:parse">Date Method: parse</a></h2>
      <p class="description">Parses a string to a date. In the examples below, parsing works with dates using / (slash), - (dash), or . (period). (12.31.2007, 12-31-2007, 12/31/2007).</p>
      <h3>Syntax</h3>
      <pre class="javascript">Date.<span class="me1">parse</span><span class="br0">(</span>date<span class="br0">)</span>;
<span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>.<span class="me1">parse</span><span class="br0">(</span>date<span class="br0">)</span>;

</pre>
      <h3>Arguments</h3>
      <ol>
        <li>date - (<em>string</em>) a string date that has a predefined parser (see <a href="#Date:defineParser">Date:defineParser</a>)</li>
      </ol>
      <h3>Example</h3>
      <pre class="javascript">Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'10/12/1982'</span><span class="br0">)</span> <span class="co1">//"Tue Oct 12 1982 00:00:00 GMT-0700 (Pacific Daylight Time)"</span>

Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'10/12/1982 10:45pm'</span><span class="br0">)</span> <span class="co1">//"Tue Oct 12 1982 22:45:00 GMT-0700 (Pacific Daylight Time)"</span>
Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'10.12.1982 22:45:00'</span><span class="br0">)</span> <span class="co1">//"Tue Oct 12 1982 22:45:00 GMT-0700 (Pacific Daylight Time)"</span>
Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'2007-06-08 16:34:52'</span><span class="br0">)</span> <span class="co1">//"Fri Jun 08 2007 16:34:52 GMT-0700 (Pacific Daylight Time)"</span>

Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'2007-06-08T16:34:52+0200'</span><span class="br0">)</span> <span class="co1">//"Fri Jun 08 2007 07:34:52 GMT-0700 (Pacific Daylight Time)"</span>
Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'Thu Oct 22 08:11:23 +0000 2009'</span><span class="br0">)</span> <span class="co1">//Thu Oct 12 2009 08:11:23 GMT (Greenwich Mean Time)</span>
&nbsp;

Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'1st'</span><span class="br0">)</span> <span class="co1">//"Sat Dec 01 2007 00:00:00 GMT-0800 (Pacific Standard Time)"</span>
Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'14th October'</span><span class="br0">)</span> <span class="co1">//"Sun Oct 14 2007 00:00:00 GMT-0700 (Pacific Daylight Time)"</span>
Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'24th May, 2007'</span><span class="br0">)</span> <span class="co1">//"Thu May 24 2007 00:00:00 GMT-0700 (Pacific Daylight Time)"</span>

Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'May 3rd 2006 10:45pm'</span><span class="br0">)</span> <span class="co1">//"Wed May 03 2006 22:45:00 GMT-0700 (Pacific Daylight Time)"</span>
&nbsp;
<span class="kw2">var</span> PrinceParty = <span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>;
PrinceParty.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'12/31/1999 11:59pm'</span><span class="br0">)</span>; <span class="co1">//PrinceParty is now set for 12/31/1999 just before midnight</span>

</pre>
      <h3>Returns</h3>
      <ul>
        <li>(<em>date</em>) a Date instance with the parsed value as its date.</li>
      </ul>
      <h3>Notes</h3>
      <ul>
        <li> <em>Date.js</em> includes many default parsers, you will get some more if you include <em><a href="../../../docs/more/Types/Date.Extras.html">Date.Extras.js</a></em> </li>
        <li>You can write your own parsers - see <a href="#Date:defineParser">Date:defineParser</a> </li>
        <li>If you execute the <em>parse</em> method against an instance of <em>Date</em>, that instance will take on the parsed value</li>
        <li>If you execute the <em>parse</em> method against the <em>Date</em> namespace a new <em>Date</em> object is created and returned</li>
      </ul>
      <h1 id="Static"><a href="#Static">Static Methods</a></h1>
      <h2 id="Date:defineFormat" class="description"><a href="#Date:defineFormat">Static Method: defineFormat</a></h2>
      <p class="description">Adds a new shortcut for <a href="#Date:format">Date:format</a>.</p>
      <h3>Syntax</h3>
      <pre class="javascript">Date.<span class="me1">defineFormat</span><span class="br0">(</span><span class="kw3">name</span>, format<span class="br0">)</span>;

</pre>
      <h3>Arguments</h3>
      <ol>
        <li>name - (<em>string</em>) name of the new format</li>
        <li>format - (<em>string</em>) format string (see <a href="#Date:format">Date:format</a>)</li>
      </ol>
      <h3>Example</h3>
      <pre class="javascript">Date.<span class="me1">defineFormat</span><span class="br0">(</span><span class="st0">'time'</span>, <span class="st0">'%H:%M'</span><span class="br0">)</span>;
<span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>.<span class="me1">format</span><span class="br0">(</span><span class="st0">'time'</span><span class="br0">)</span>;  <span class="co1">//17:30</span>

</pre>
      <h2 id="Date:defineFormats"><a href="#Date:defineFormats">Static Method: defineFormats</a></h2>
      <p class="description">Add a new shortcuts for <a href="#Date:format">Date:format</a>.  Plural form of <a href="#Date:defineFormat">Date:defineFormat</a>.</p>
      <h3>Syntax</h3>
      <pre class="javascript">Date.<span class="me1">defineFormats</span><span class="br0">(</span>formats<span class="br0">)</span>;

</pre>
      <h3>Arguments</h3>
      <ol>
        <li>formats - (<em>object</em>) key/value pairs corresponding to the name and format passed into <a href="#Date:defineFormat">Date:defineFormat</a> </li>
      </ol>
      <h3>Example</h3>
      <pre class="javascript">Date.<span class="me1">defineFormats</span><span class="br0">(</span><span class="br0">{</span>

    time: <span class="st0">'%H:%M'</span>,
    day: <span class="st0">'%A'</span>
<span class="br0">}</span><span class="br0">)</span>;
</pre>
      <h2 id="Date:staticParse"><a href="#Date:staticParse">Static Method: parse</a></h2>
      <p class="description">See <a href="#Date:parse">Date:parse</a> above.</p>
      <h2 id="Date:defineParser"><a href="#Date:defineParser">Static Method: defineParser</a></h2>
      <p class="description">Additional parsers can be authored than those already outlined by default in <em>Date.js</em>. If you include <em>Date.Extras.js</em> you'll get several more, but you can write your own.</p>
      <h3>Syntax</h3>
      <pre class="javascript">Date.<span class="me1">defineParser</span><span class="br0">(</span>pattern<span class="br0">)</span>;

</pre>
      <h3>Arguments</h3>
      <ul>
        <li>pattern - (<em>string</em> or <em>object</em>) see descriptions below.</li>
      </ul>
      <h3>Pattern String</h3>
      <p>A pattern string is somewhat of a hybrid between regular expressions and the format strings passed into <a href="#Date:format">Date:format</a>. First, an example:</p>
      <pre class="javascript">Date.<span class="me1">defineParser</span><span class="br0">(</span><span class="st0">'%d%o( %b( %Y)?)?( %X)?'</span><span class="br0">)</span>;
</pre>
      <p>As you can see, the above pattern (already included in <em>Date.js</em>) uses parentheses for grouping with a question mark to denote the preceding item or group as being optional, just as in a regular expression.  It parsers strings such as:</p>
      <ul>
        <li>14th</li>
        <li>31st October</li>
        <li>1 Jan 2000</li>
        <li>1 Jan 12:00am</li>
      </ul>
      <p>All of the same keys that are supported in <a href="#Date:format">Date:format</a> are supported here, except <strong>%c</strong>, <strong>%U</strong>, <strong>%w</strong>, and <strong>%Z</strong>.  However, the matching rules for each key is as loose as possible in order to parse the greatest number of variations.</p>
      <h3>Custom Pattern Object</h3>
      <p>Each custom pattern object has two properties: a regular expression and a handler that is passed the result of that expression executed on the string to be parsed.</p>
      <pre class="javascript">Date.<span class="me1">defineParser</span><span class="br0">(</span><span class="br0">{</span>
    re: &lt;regularExpression&gt;,
    handler: <span class="kw2">function</span><span class="br0">(</span>bits<span class="br0">)</span><span class="br0">{</span>...<span class="br0">}</span>

<span class="br0">}</span><span class="br0">)</span>;
</pre>
      <h3>Notes</h3>
      <p>The legacy method of adding parsers is still supported but considered deprecated.</p>
      <pre class="javascript">Date.<span class="me1">parsePatterns</span>.<span class="me1">push</span><span class="br0">(</span>pattern<span class="br0">)</span>;
Date.<span class="me1">parsePatterns</span>.<span class="me1">extend</span><span class="br0">(</span><span class="br0">[</span>pattern, pattern, etc<span class="br0">]</span><span class="br0">)</span>;

</pre>
      <h2 id="Date:defineParsers"><a href="#Date:defineParsers">Static Method: defineParsers</a></h2>
      <p class="description">Plural form of <a href="#Date:defineParser">Date:defineParser</a>.</p>
      <h3>Syntax</h3>
      <pre class="javascript">Date.<span class="me1">defineParsers</span><span class="br0">(</span>pattern, pattern, etc.<span class="br0">)</span>;

</pre>
      <h3>Arguments</h3>
      <ol>
        <li>format - can be multiple format arguments or an array of formats.</li>
      </ol>
      <h2 id="Date:define2DigitYearStart"><a href="#Date:define2DigitYearStart">Static Method: define2DigitYearStart</a></h2>
      <p class="description">Define the first year of the 100-year period that 2-digit years will be fall within when parsed.  The default start year is 1970.</p>
      <h3>Syntax</h3>
      <pre class="javascript">Date.<span class="me1">define2DigitYearStart</span><span class="br0">(</span>year<span class="br0">)</span>
</pre>
      <h3>Arguments</h3>
      <ol>
        <li>year - (<em>integer</em>) first year of the 100-year period</li>
      </ol>
      <h3>Example</h3>
      <pre class="javascript">Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'01/01/00'</span><span class="br0">)</span>;  <span class="co1">//Jan 1, 2000</span>
Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'12/31/99'</span><span class="br0">)</span>;  <span class="co1">//Dec 31, 1999</span>

&nbsp;
Date.<span class="me1">define2DigitYearStart</span><span class="br0">(</span><span class="nu0">2000</span><span class="br0">)</span>;
Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'01/01/00'</span><span class="br0">)</span>;  <span class="co1">//Jan 1, 2000</span>
Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'12/31/99'</span><span class="br0">)</span>;  <span class="co1">//Dec 31, 2099</span>

</pre>
    </div>
  </div>
<script type="text/javascript" src="../../../assets/mootools-core-1.3.js"></script>
<script type="text/javascript" src="../../../assets/mootools-more-smoothscroll.js"></script>
<script type="text/javascript" src="../../../assets/doc-assist.js"></script>
</body>
</html>
